package com.sc.nft.entity.vo;

import cn.hutool.core.convert.Convert;
import com.sc.nft.enums.ApplicationRequirementEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
public class ApplicationRequirementFactoryVO {

    @ApiModelProperty("文字描述")
    private String key;

    @ApiModelProperty("小文字描述")
    private String smallCharacter;

    @ApiModelProperty("藏品名称")
    private List<String>collectionNames;

    @ApiModelProperty("要求值")
    private Integer askForValue;

    @ApiModelProperty("要求值")
    private String askForValueStr;

    @ApiModelProperty("实际值")
    private Integer practicalValue;

    @ApiModelProperty("实际值")
    private String practicalValueStr;

    @ApiModelProperty("是否满足要求")
    private Boolean satisfy;

    @ApiModelProperty("标识")
    private ApplicationRequirementEnum applicationRequirementEnum;

    @ApiModelProperty("数量,目前就持有藏品可以用到")
    private Integer quantity;


    public void setPracticalValueStr(Integer practicalValueStr) {
        if (practicalValueStr==null) {
            this.practicalValueStr = "0";
            return;
        }
        if (practicalValueStr>=10000) {
            this.practicalValueStr = Convert.toStr(Convert.toBigDecimal(practicalValueStr).movePointLeft(4).setScale(2, BigDecimal.ROUND_DOWN).stripTrailingZeros().toPlainString())+"万";
            return;
        }
        this.practicalValueStr = Convert.toStr(practicalValueStr);
    }
    public void setAskForValue(String askForValue) {
//        if (
//                applicationRequirementEnum == ApplicationRequirementEnum.TOTAL_HOLDINGS_OF_TEAM_COLLECTIONS ||
//                applicationRequirementEnum == ApplicationRequirementEnum.TOTAL_TEAM_ECO_MELTING_VALUE) {
//            this.askForValue = Convert.toInt(Convert.toBigDecimal(askForValue).divide(Convert.toBigDecimal(10000)).longValue());
//        } else {this.askForValue = Convert.toInt(askForValue);
//
//        }
        this.askForValue = Convert.toInt(askForValue);

        if (askForValue==null) {
            this.askForValueStr = "0";
            return;
        }
        if (Convert.toInt(askForValue)>=10000) {
            this.askForValueStr = Convert.toStr(Convert.toBigDecimal(askForValue).movePointLeft(4).setScale(2, BigDecimal.ROUND_DOWN).stripTrailingZeros().toPlainString())+"万";
            return;
        }
        this.askForValueStr = Convert.toStr(askForValue);
    }

    public void setPracticalValue(Integer practicalValue) {
        this.practicalValue = practicalValue==null?0:practicalValue;
    }

}
